#ifndef FIERECVMANAGER_H
#define FIERECVMANAGER_H

#include <QObject>
#include "FileDB.h"

class FileRecvManager : public QObject
{
	Q_OBJECT

public:
	FileRecvManager();
	~FileRecvManager();
	
signals:
	void RequireFile(int fileId);
	void RequireFile(int fileId, int blockIndex);
	void TransferFinish();

public:
	void SetPathTable(const seven::PathTable* table);
	void SetFileTable(const seven::FileTable* table);
	
	void Start();
	void RequireFiles();
	void RecvFile(int fileId,const char* buff,int size);
	void RecvFileBlock(int fileId, int blockIndex, char* buff, int size);
	void SetPath(const QString& path);

	void Reset();
private:
	QSharedPointer<FileDB> srcFileDB;
	QVector<bool> fileFinished;
	int curTransferFileIndex;
	QString recvPath; 
	static const int fileBlockSize = 1024 * 1024;
};

#endif // FIERECVMANAGER_H
